/**
 * Created by SPG on 2016/7/5.
 */
var privateJsonString = function (object) {
    var type = typeof object;
    try {
        if ('object' === type && Array === object.constructor) {
            type = 'array';
        }
    } catch (e) {
    }
    switch (type) {
        case 'number':
            return object ? ("" + object) : "0";
        case 'string':
            return '"' + object.replace(/(\\|\")/g, "\\$1") + '"';
        case 'object':
            var results = [];
            for (var property in object) {
                results.push('"' + property + '":' + privateJsonString(object[property]));
            }
            return '{' + results.join(',') + '}';
        case 'array':
            var results = [];
            for (var i = 0; i < object.length; i++) {
                results.push(object[i] ? privateJsonString(object[i]) : "null");
            }
            return '[' + results.join(',') + ']';
        default :
            return (object === undefined) ? ("" + object) : "null";
    }
};